package org.glut.cloud.video.controller;

import org.glut.cloud.video.entity.Video;
import org.glut.cloud.video.service.IVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 视频信息表 前端控制器
 *
 * @author qjc
 * @since 2024-08-12 16:20
 */
@RestController
@RequestMapping
public class VideoController {
    @Autowired
    private IVideoService iVideoService;

    @PostMapping("/video/save")
    public ResponseEntity<String> saveVideo(@RequestBody Video video) {
        // 设置创建时间和更新时间
        video.setGmtCreated(new Date());
        video.setGmtUpdated(new Date());

        // 默认设置逻辑删除状态为0（未删除）
        video.setIsDeleted(0);

        // 调用服务层保存视频信息
        iVideoService.save(video);

        return ResponseEntity.ok("视频信息保存成功");
    }
}
